#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int>index;
//通过二分查找原下标离散化后的位置
//二分的坑再在于调整边界如果令某边界==mid\
//只剩两个数的情况下mid不能取到这个边界,不然死循环(调整上下取整)
int find(int i){
    int l=0;
    int r=index.size()-1;
    while(l<r){
        int mid =(l+r+1)>>1;
        if(index[mid]>i)
            r=mid-1;
        else
            l=mid;
    }
    return l;
}
int main(){
    int n,m;
    vector<pair<int,int>>add;
    vector<pair<int,int>>req;
    cin>>n>>m;
    //保存操作
    for(int t=0;t<n;t++){
        int i,x;
        cin>>i>>x;
        //存储要用到的下标
        add.push_back({i,x});
        index.push_back(i);
    }
    //保存问询
    for(int i=0;i<m;i++){
        int l,r;
        cin>>l>>r;
        req.push_back({l,r});
        //存储下标
        index.push_back(l);
        index.push_back(r);
    }
    //去重+排序 (为了二分,映射)
    //1.set 倒过去在倒回来
    //2.unique[l,r)->first removed element + erase[l,r)->element that followed last erased element 
    sort(index.begin(),index.end());
    index.erase(unique(index.begin(),index.end()),index.end());
    //新数组 离散化(借助二分)
    vector<int>arr(index.size(),0);
    //处理操作
    for(auto&e:add){
        arr[find(e.first)]+=e.second;
    }
    //前缀和 
    vector<int>sum(arr.size()+1,0);
    for(int i=1;i<sum.size();i++){
        sum[i]=sum[i-1]+arr[i-1];
    }
    //处理问询
    for(auto&e:req){
        int l=e.first;
        int r=e.second;
        cout<<sum[find(r)+1]-sum[find(l)]<<endl;
    }
    return 0;
}